package com.stox.ui.javafx.charting.draw.shape;

import javafx.scene.canvas.GraphicsContext;
import javafx.scene.paint.Color;

import com.stox.ui.javafx.charting.widget.ResizableCanvas;

public class TrendLine extends AbstractLine{

	private final ControlPoint endPoint;
	private final DragPoint dragPoint;
	private ControlPoint editPoint;
	private boolean finished;
	
	public TrendLine(ResizableCanvas canvas) {
		super(canvas);
		this.endPoint = new ControlPoint(canvas);
		this.dragPoint = new DragPoint(canvas);
		this.editPoint = endPoint;
	}

	public ControlPoint getDragPoint(){
		return dragPoint;
	}
	
	public ControlPoint getEndPoint() {
		return endPoint;
	}
	
	public ControlPoint getEditPoint() {
		return editPoint;
	}
	
	public void setEditPoint(ControlPoint editPoint) {
		this.editPoint = editPoint;
	}
	
	public boolean isFinished() {
		return finished;
	}
	
	public void setFinished(boolean finished) {
		this.finished = finished;
	}
	
	@Override
	public void update() {
		super.update();
		if(null != endPoint){
			endPoint.update();
		}
	}
	
	@Override
	public void paint() {
		GraphicsContext gc = getCanvas().getGraphicsContext2D();
		// TODO : Get color from settings
		gc.setLineWidth(0.5);
		gc.setStroke(Color.LIGHTBLUE);
		gc.strokeLine(getPoint().getX(), getPoint().getY(), getEndPoint().getX(), getEndPoint().getY());
	}

}
